/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mobilevikings.app;

import com.mobilevikings.app.api.ApiConnection;
import com.mobilevikings.util.Properties;
import com.mobilevikings.util.PropertiesFactory;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;

/**
 *
 * @author Jeroen
 */
public abstract class Function implements CommandListener {

    protected Display mDisplay;
    protected Displayable mPreviousScreen;
    protected Properties mProperties;
    protected ApiConnection mNetlogConnection;
    protected Command mCmdPrevious;
    protected Command mCmdCancel;
    protected boolean mCancelled;

    /**
     * Constructor of the abstract class Function
     * @param inDisplay the Display of the MIDlet
     */
    public Function(Display inDisplay) {
        this.mDisplay = inDisplay;
        mPreviousScreen = mDisplay.getCurrent();
        mProperties = PropertiesFactory.getProperties();
        mNetlogConnection = ApiConnection.getInstance();
        mCmdPrevious = new Command(mProperties.get("BACK"), Command.BACK, 1);
        mCmdCancel = new Command(mProperties.get("CANCEL"), Command.CANCEL, 1);
        mCancelled = false;
    }

    /**
     * Will show a user interface according to the function
     */
    public abstract void show();

    /**
     * Gets the display
     * @return the mDisplay
     */
    public Display getMDisplay() {
        return mDisplay;
    }

    /**
     * Gets the previous Screen
     * @return the mPreviousScreen
     */
    public Displayable getMPreviousScreen() {
        return mPreviousScreen;
    }

    /**
     * Sets the previous Screen
     * @param inPreviousScreen
     */
    public void setMPreviousScreen(Displayable inPreviousScreen) {
        this.mPreviousScreen = inPreviousScreen;
    }

    /**
     * Gets the properties
     * (used to access all the Strings in the application)
     * @return the mProperties
     */
    public Properties getMProperties() {
        return mProperties;
    }

    /**
     * Gets the NetlogConnection
     * @return the mNetlogConnection
     */
    public ApiConnection getMNetlogConnection() {
        return mNetlogConnection;
    }

    /**
     * Gets the Cancel command
     * @return the cancel command
     */
    public Command getMCmdCancel() {
        return mCmdCancel;
    }
}
